# 集成学习：
# bagging:模型独立，共同表决
# boosting:模型有序，逐渐提升

from sklearn.datasets import load_wine
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier, BaggingClassifier, AdaBoostClassifier
from sklearn.tree import DecisionTreeClassifier


x, y = load_wine(return_X_y=True)
train_x, test_x, train_y, test_y = train_test_split(x, y, test_size=0.3, random_state=0)
dtc = DecisionTreeClassifier(random_state=22).fit(train_x, train_y)
rfc = RandomForestClassifier(random_state=22).fit(train_x, train_y)
print(dtc.score(test_x, test_y))
print(rfc.score(test_x, test_y))

bgc = BaggingClassifier(random_state=22).fit(train_x, train_y)
print(bgc.score(test_x, test_y))
adc = AdaBoostClassifier(learning_rate=0.1, random_state=22).fit(train_x, train_y)
print(adc.score(test_x, test_y))

